using namespace std;
#include <iostream>
#include <Windows.h>
#include <fstream>
#include "main.h"

void main(int argc, char **argv)
{
	int x = 0;
	int y = 0;


	cout << "Starting in 5..." << endl;
	Sleep(1000);
	cout << "Starting in 4..." << endl;
	Sleep(1000);
	cout << "Starting in 3..." << endl;
	Sleep(1000);
	cout << "Starting in 2..." << endl;
	Sleep(1000);
	cout << "Starting in 1..." << endl;
	Sleep(1000);

	mouseMove(35, 662);
	click();
	click();

	cout << "Finished" << endl;

}


void mouseMove(int x, int y)
{
	double width = 0;
	double height = 0;
	double fx = 0;
	double fy = 0;
	INPUT input = { 0 };
	ofstream infile;

	infile.open("C:\\Users\\Tyler Sanger\\Desktop\\log.txt");

	width = GetSystemMetrics(SM_CXSCREEN) - 1;
	height = GetSystemMetrics(SM_CYSCREEN) - 1;
	fx = x*(65535.0f / width);
	fy = y*(65535.0f / height);

	infile << width << endl;
	infile << height << endl;
	infile << fx << endl;
	infile << fy << endl;
	infile.close();

	input.type = INPUT_MOUSE;
	input.mi.dx = fx;
	input.mi.dy = fy;
	input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;

	SendInput(1, &input, sizeof(INPUT));
}

void click(void)
{
	INPUT input = { 0 };
	input.type = INPUT_MOUSE;
	input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
	SendInput(1, &input, sizeof(INPUT));

	ZeroMemory(&input, sizeof(INPUT));
	input.type = INPUT_MOUSE;
	input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
	SendInput(1, &input, sizeof(INPUT));
}